home *** CD-ROM | disk | FTP | other *** search
/ 3D Games (Spidla) / 3dhry1.iso / mAz Lite 1.0 / weapons.wdl < prev    next >
Encoding:
Text File  |  2003-03-17  |  50.3 KB  |  1,955 lines

  1. // Template file v5.202 (02/20/02)
  2. ////////////////////////////////////////////////////////////////////////
  3. // File: weapons.wdl
  4. //        WDL prefabs for weapon entities & effects
  5. ////////////////////////////////////////////////////////////////////////
  6. //
  7. //
  8. // Mod: 02/13/02 DCP
  9. //         ACTION gun: Removed default _AMMOTYPE (if _AMMOTYPE = 0, gun has unlimited ammo)
  10. //            gun_restore(): Added 'gun_loaded = 1' to reload repeating guns.
  11. //
  12. ////////////////////////////////////////////////////////////////////////
  13. //
  14. ////////////////////////////////////////////////////////////////////////
  15.  
  16. // change these sounds and graphics for your weapon
  17. IFNDEF WEAPON_DEFS;
  18.  SOUND gun_click,<empty.wav>;
  19.  SOUND gun_wham,<wham.wav>;
  20.  SOUND explo_wham,<explo.wav>;
  21.  DEFINE hit_wham,explo_wham;
  22.  SOUND gun_fetch,<beamer.wav>;
  23.  DEFINE ammo_fetch,gun_fetch;
  24.  DEFINE health_fetch,gun_fetch;
  25.  
  26.  DEFINE muzzle_flash,<particle.pcx>;
  27.  DEFINE small_flash,<particle.pcx>;
  28.  DEFINE fireball,<blitz.pcx>;
  29.  DEFINE BULLET_EXPLO,<explo+7.pcx>;
  30.  DEFINE EXPLO_FRAMES,7;
  31.  DEFINE WEAPON_AMPL,0.2;    // swaying
  32. ENDIF;
  33.  
  34. IFNDEF WEAPON_DEFS2;
  35.  DEFINE bullethole_map,<bulhole.pcx>;    // bullet hole bitmap ***
  36.  DEFINE ibullethole_map,<ibulhole.pcx>;    // inverted bullet hole bitmap (white) ***
  37. ENDIF;
  38.  
  39. //////////////////////////////////////////////////////////////////////
  40. // adapt those skills and strings to your game
  41. // ammo starting and maximum values
  42. var ammo1[3] = 0, 0, 200;
  43. var ammo2[3] = 0, 0, 100;
  44. var ammo3[3] = 0, 0,  40;
  45. var ammo4[3] = 0, 0,  10;
  46. var ammo5[3] = 0, 0,  10;
  47. var ammo6[3] = 0, 0,  10;
  48. var ammo7[3] = 0, 0,  10;
  49.  
  50. // dynamic light values
  51. var light_explo[3]  =  50,  50, 255;// { RED 50; GREEN 50; BLUE 255; }
  52. var light_flash[3]  = 200, 150,  50;// { RED 200; GREEN 150; BLUE 50; }
  53. var light_muzzle[3] = 200,  20,  20;// { RED 200; GREEN 20; BLUE 20; }
  54. var light_bullet[3] = 200,  50,  20;// { RED 200; GREEN 50; BLUE 20; }
  55.  
  56.  
  57.  
  58. // you'll probably want to redefine those strings. No problem.
  59. STRING got_ammo1_str,"Got an ammo pack!";
  60. STRING got_ammo2_str,"Got a big ammo pack!";
  61. STRING got_ammo3_str,"Got a grenade pack!";
  62. STRING got_ammo4_str,"Got a battery pack!";
  63. STRING got_ammo5_str,"Got ammo5 pack!";
  64. STRING got_ammo6_str,"Got a rocket pack!";
  65. STRING got_ammo7_str,"Got ammo7 pack!";
  66.  
  67. STRING got_medi_str,"Got a first aid kit!";
  68. STRING got_gun1_str,"Got a small gun!";
  69. STRING got_gun2_str,"Got a medium gun!";
  70. STRING got_gun3_str,"Got a large gun!";
  71. STRING got_gun4_str,"Got a laser gun!";
  72. STRING got_gun5_str,"Got a shotgun!";
  73. STRING got_gun6_str,"Got a rocket launcher!";
  74. STRING got_gun7_str,"Got a gun no. 7!";
  75.  
  76. //////////////////////////////////////////////////////////////////////
  77. /* Gun Action
  78.  
  79. FLAG1  (__ROTATE from doors.wdl)
  80.     If this flag is set, the gun model rotates before being picked up.
  81.  
  82. FLAG2  (__SILENT from doors.wdl)
  83.     If this flag is set, the message on picking up the item will be
  84.     suppressed.
  85.  
  86. FLAG5  (__BOB from movement.wdl)
  87.    If this flag is marked, the gun sways a little if the camera is
  88.     moving. The sway period is the same as used for head bobbing in the
  89.     movement.wdl. If the flag is not marked, the gun stands still.
  90.  
  91. FLAG7  (__REPEAT)
  92.    If this flag is marked, it's a machine gun. Otherwise, a single
  93.     action gun.
  94.  
  95. SKILL1..SKILL3   (_OFFS_X, _OFFS_Y, _OFFS_Z)
  96.     X Y Z position of the gun relative to the camera.
  97.  
  98. SKILL4  (_AMMOTYPE)
  99.     Ammo type (1..7). If 0, the gun doesn't consume ammunition. The part
  100.     after the decimal, times 100, gives the amount of ammo to be added
  101.     on picking up the gun. E.g. 2.30 = Ammo type 2, 30 rounds are
  102.     already in the gun.
  103.  
  104. SKILL5 (_BULLETSPEED)
  105.     Speed of the bullet, default = 200 quants / tick. The part after the
  106.     decimal, times 10, gives the strength of the recoil. If 0, then
  107.     there is no recoil. If SKILL5 is above 0, the recoil is done by
  108.     moving backwards. If SKILL5 is below 0, then the recoil is done by
  109.     swinging upwards.
  110.  
  111. SKILL6  (_WEAPONNUMBER)
  112.     Weapon number that determines the key (1..7) to be pressed to select
  113.     that gun.
  114.  
  115. SKILL7  (_FIRETIME)
  116.    The time (in ticks) the gun needs to reload. Includes the time for
  117.    the gun animation, if any.
  118.  
  119. SKILL8 (_FIREMODE from movement.wdl)
  120.    Fire mode, can be composed by adding the following numbers:
  121.  
  122.     1 - Damage is applied by a SHOOT instruction, without bullet (DAMAGE_SHOOT).
  123.     2 - Damage is applied by IMPACT of the bullet (DAMAGE_IMPACT).
  124.     3 - Damage is applied by a SCAN explosion of the bullet (DAMAGE_EXPLODE).
  125.  
  126.     4 - the gun fires line of particles (FIRE_PARTICLE).
  127.     8 - the gun fires single particles (FIRE_DPARTICLE).
  128.     12 - the gun fires orange fireballs, which radiate light (FIRE_BALL).
  129.     16 - the gun fires a rocket model w/smoke trail (FIRE_ROCKET)
  130.     20 - (NEW 11/17/00) the gun fires a laser (FIRE_LASER)
  131.     24 - Reserved
  132.     28 - Reserved
  133.  
  134.     32 - the bullets leave smoke trails(BULLET_SMOKETRAIL).
  135.  
  136.     64 - reserved
  137.  
  138.     128 - at hit point there will be a light flash (HIT_FLASH).
  139.     256 - at hit point there will be an explosion (HIT_EXPLO).
  140.     384 - at hit point there will be a big explosion (HIT_GIB).
  141.  
  142.     512 - at hit point a cloud of smoke will ascend (HIT_SMOKE).
  143.  
  144.     1024 - there will be multiple hit points, as by a shotgun (HIT_SCATTER).
  145.  
  146.     2048 - the gun spits out cartridge cases (GUNFX_BRASS).
  147.  
  148.     4096 - the bullets follow gravity.
  149.  
  150.     8192 - at hit point a shower of sparks (HIT_SPARKS).
  151.  
  152.     16384 - bullet hole at hit point (HIT_HOLE)
  153.  
  154.     32768 - gun has a "shot" animation (GUNFX_ANIMATE)
  155.  
  156.     The part after the decimal, times 100, gives the amount of damage
  157.     the bullet produces (default = 10).  ***
  158.  
  159. SKILL11..SKILL13   (_GUN_SOURCE_X, _GUN_SOURCE_Y, _GUN_SOURCE_Z)
  160.     X Y Z offset position of the bullet starting point (in 1st person view)
  161.     if X == 0 then the gun muzzle will be used.
  162.  
  163. SKILL14 (_OFFS_FLASH )
  164.     Muzzle flash offset in X direction.
  165.  
  166. SKILL15 (_RECOIL)
  167.     Weapon recoil value.
  168.  
  169. SKILL16 (_DAMAGE)
  170.     Damage from weapon
  171.  
  172. SKILL17 (_DISPLACEMENT)
  173.     Distance weapon is 'displaced'
  174.  
  175. SKILL18 (
  176.  
  177. */
  178. ///////////////////////////////////////////////////////////////////////
  179.  
  180. // Define Flags
  181. //FLAG1 = __ROTATE from doors.wdl
  182. //FLAG2 = __SILENT from doors.wdl
  183. //FLAG5 = __BOB from movement.wdl
  184. DEFINE __REPEAT,FLAG7;
  185.  
  186. // Define SKILLs
  187. DEFINE _OFFS_X,SKILL1;
  188. DEFINE _OFFS_Y,SKILL2;
  189. DEFINE _OFFS_Z,SKILL3;
  190. DEFINE _AMMOTYPE,SKILL4;
  191. DEFINE _BULLETSPEED,SKILL5;
  192. DEFINE _WEAPONNUMBER,SKILL6;
  193. DEFINE _FIRETIME,SKILL7;
  194. //SKILL8 = _FIREMODE from movement.wdl
  195.  
  196. DEFINE _GUN_SOURCE_X,SKILL11;
  197. DEFINE _GUN_SOURCE_Y,SKILL12;
  198. DEFINE _GUN_SOURCE_Z,SKILL13;
  199.  
  200.  
  201. DEFINE _OFFS_FLASH,SKILL14;
  202. DEFINE _RECOIL,SKILL15;
  203. DEFINE _DAMAGE,SKILL16;
  204. DEFINE _DISPLACEMENT,SKILL17;
  205. DEFINE _FIRE,SKILL18;
  206.  
  207. DEFINE _PACKAMOUNT, SKILL5;    // ammo/med pack ammo amounts
  208.  
  209. // Constants
  210. DEFINE MODE_DAMAGE,3;
  211. DEFINE DAMAGE_SHOOT,1;
  212. DEFINE DAMAGE_IMPACT,2;
  213. DEFINE DAMAGE_EXPLODE,3;
  214.  
  215. DEFINE MODE_FIRE,28;
  216. DEFINE FIRE_PARTICLE,4;
  217. DEFINE FIRE_DPARTICLE,8;
  218. DEFINE FIRE_BALL,12;
  219. DEFINE FIRE_ROCKET,16;
  220. DEFINE FIRE_LASER,20;
  221.  
  222. DEFINE BULLET_SMOKETRAIL,32;
  223.  
  224. DEFINE MODE_HIT,384;
  225. DEFINE HIT_FLASH,128;
  226. DEFINE HIT_EXPLO,256;
  227. DEFINE HIT_GIB,384;
  228.  
  229. DEFINE HIT_SMOKE, 512;
  230.  
  231. DEFINE HIT_SCATTER,1024;
  232. DEFINE GUNFX_BRASS,2048;        // gun drops brass
  233.  
  234. DEFINE HIT_SPARKS,8192;
  235.  
  236. DEFINE HIT_HOLE 16384;
  237.  
  238. DEFINE GUNFX_ANIMATE, 32768;     // gun has a firing animation
  239.  
  240.  
  241. ///////////////////////////////////////////////////////////////////////
  242. entity* weapon;
  243. // The weapon must be a model pointing into X-direction,
  244. // its center must be inside the barrel.
  245.  
  246. DEFINE    kMaxWeapons = 7;
  247.  
  248. entity* weapon1;
  249. entity* weapon2;
  250. entity* weapon3;
  251. entity* weapon4;
  252. entity* weapon5;
  253. entity* weapon6;
  254. entity* weapon7;
  255.  
  256. entity* weaponTmpSyn;     // tmp ENTITY pointer
  257.  
  258.  
  259. var weapon_1 = 0;     // set to 1 if the player owns that weapon
  260. var weapon_2 = 0;
  261. var weapon_3 = 0;
  262. var weapon_4 = 0;
  263. var weapon_5 = 0;
  264. var weapon_6 = 0;
  265. var weapon_7 = 0;
  266.  
  267. var gun_muzzle[3];
  268. var gun_source[4];    // trace start point   (gun_source[3] = 9 if used)
  269. var gun_target[3];
  270. var gun_loaded = 1;
  271. var fireball_speed = 0;
  272.  
  273. var weapon_number = 0;
  274. var ammo_number = 0;
  275.  
  276. var range = 0;
  277. var damage = 0;
  278. var fire_mode = 0;
  279. var weapon_firing = 0;
  280.  
  281. //////////////////////////////////////////////////////////////////////
  282.  
  283. // 'Default' First Person Shooter guns
  284. /****************************************************************
  285.     Weapon Actions - Some pre-defined weapons
  286.  
  287.     todo: perhaps come up with a way to have the world
  288.     models (laying on the ground) separate and different
  289.     from the view models (in player's hand).
  290. ******************************************************************/
  291.  
  292.  
  293. // Desc: basic animated machinegun type weapon
  294. //
  295. // Created: 07/25/01 DCP
  296. //
  297. // uses _WEAPONNUMBER
  298. // uses __ROTATE
  299. action weap_mg_animated
  300. {
  301.     MY.__ROTATE = ON;        // gun rotates before being picked up
  302.     MY.__REPEAT = ON;        // repeats (Auto-fire)
  303.     MY.__BOB = ON;          // 'bobs' when the player moves
  304.     MY._OFFS_X = 45;       // x,y,z pos of the gun
  305.     MY._OFFS_Y = 15;
  306.     MY._OFFS_Z = 15;
  307.     MY._AMMOTYPE = 1.99;               // type of ammo '.' rounds in gun
  308.  
  309.     if (MY._WEAPONNUMBER == 0) { MY._WEAPONNUMBER = 2; }            // weapon number (press to equip)
  310.     MY._BULLETSPEED = 1000.01;        // bulletspeed '.' recoil
  311.     MY._FIRETIME = 2;              // time to cycle (reload)
  312.  
  313.     // SHOOT damage (immediate)
  314.     // + hole at hit point
  315.     // + eject brass
  316.     // + gun "shot" animation
  317.     // 20 points of damage per shot
  318.     MY._FIREMODE = DAMAGE_SHOOT + HIT_HOLE + GUNFX_BRASS + GUNFX_ANIMATE + 0.20;
  319.     gun();
  320. }
  321.  
  322.  
  323. // Desc: basic 'M16' type weapon
  324. //
  325. // Created: MWS 06/25/01
  326. //
  327. // uses _WEAPONNUMBER
  328. // uses __SILENT
  329. action weap_m16
  330. {
  331.     MY.__ROTATE = ON;        // gun rotates before being picked up
  332.     MY.__REPEAT = ON;        // repeats (Auto-fire)
  333.     MY.__BOB = ON;          // 'bobs' when the player moves
  334.     MY._OFFS_X = 30;       // x,y,z pos of the gun
  335.     MY._OFFS_Y = 10;
  336.     MY._OFFS_Z = 10;
  337.     MY._AMMOTYPE = 1.30;               // type of ammo '.' rounds in gun
  338.  
  339.     if (MY._WEAPONNUMBER == 0) { MY._WEAPONNUMBER = 1; }            // weapon number (press to equip)
  340.     MY._BULLETSPEED = 1000.01;        // bulletspeed '.' recoil
  341.     MY._FIRETIME = 1;              // time to cycle (reload)
  342.  
  343.     // SHOOT damage (immediate)
  344.     // + flash at hit point
  345.     // + sparks at hit point
  346.     // 10 points of damage per shot
  347.     MY._FIREMODE = DAMAGE_SHOOT + HIT_HOLE + HIT_FLASH + HIT_SPARKS + 0.10;
  348.     gun();
  349. }
  350.  
  351. // Desc: basic 'rocket launcher' type weapon
  352. //
  353. // Created: MWS 06/25/01
  354. //
  355. // uses _WEAPONNUMBER
  356. // uses __SILENT
  357. action weap_rocketlauncher
  358. {
  359.     MY.__ROTATE = ON;        // gun rotates before being picked up
  360.     MY.__REPEAT = ON;        // repeats (Auto-fire)
  361.     MY.__BOB = ON;          // 'bobs' when the player moves
  362.     MY._OFFS_X = 35;       // x,y,z pos of the gun
  363.     MY._OFFS_Y = 10;
  364.     MY._OFFS_Z = 10;
  365.     MY._AMMOTYPE = 6.10;               // type of ammo '.' rounds in gun
  366.  
  367.     if (MY._WEAPONNUMBER == 0) { MY._WEAPONNUMBER = 6; }            // weapon number (press to equip)
  368.     MY._BULLETSPEED = 200.10;        // bulletspeed '.' recoil
  369.     MY._FIRETIME = 10;              // time to cycle (reload)
  370.  
  371.     // SHOOT damage (immediate)
  372.     // + flash at hit point
  373.     // + sparks at hit point
  374.     // 50 points of damage per shot
  375.     MY._FIREMODE = DAMAGE_EXPLODE + FIRE_ROCKET + HIT_GIB + HIT_SPARKS + 0.50;
  376.     gun();
  377. }
  378.  
  379. /**************************************************************
  380.     Ammo Actions - Default ammopacs from weapons.wdl,
  381.     but with specific ammunition types (to simplify
  382.     things for the WED user).  Uses defines from weapons.wdl,
  383.     thus must be included after it.
  384.  
  385. ***************************************************************/
  386.  
  387. // Desc: ammo boxes (weapons 1-7)
  388. //
  389. // Created: MWS 06/25/01
  390. //
  391. // uses _PACKAMOUNT
  392. // uses __SILENT
  393. action ammo_type1
  394. {
  395.     MY.__ROTATE = ON;
  396.     MY._AMMOTYPE = 1;
  397.     ammopac();
  398. }
  399.  
  400. // uses _PACKAMOUNT
  401. // uses __SILENT
  402. action ammo_type2
  403. {
  404.     MY.__ROTATE = ON;
  405.     MY._AMMOTYPE = 2;
  406.     ammopac();
  407. }
  408.  
  409. // uses _PACKAMOUNT
  410. // uses __SILENT
  411. action ammo_type3
  412. {
  413.     MY.__ROTATE = 1;
  414.     MY._AMMOTYPE = 3;
  415.     ammopac();
  416. }
  417.  
  418. // uses _PACKAMOUNT
  419. // uses __SILENT
  420. action ammo_type4
  421. {
  422.     MY.__ROTATE = 1;
  423.     MY._AMMOTYPE = 4;
  424.     ammopac();
  425. }
  426.  
  427. // uses _PACKAMOUNT
  428. // uses __SILENT
  429. action ammo_type5
  430. {
  431.     MY.__ROTATE = 1;
  432.     MY._AMMOTYPE = 5;
  433.     ammopac();
  434. }
  435.  
  436. // uses _PACKAMOUNT
  437. // uses __SILENT
  438. action ammo_type6
  439. {
  440.     MY.__ROTATE = 1;
  441.     MY._AMMOTYPE = 6;
  442.     ammopac();
  443. }
  444.  
  445. // uses _PACKAMOUNT
  446. // uses __SILENT
  447. action ammo_type7
  448. {
  449.     MY.__ROTATE = 1;
  450.     MY._AMMOTYPE = 7;
  451.     ammopac();
  452. }
  453.  
  454.  
  455.  
  456. // testgun, logangun, lasergun, sparkgun, & flashgun are all examples
  457. //on how to create guns with the template code. Each one calls 'gun'.
  458.  
  459. // Desc: a testgun. This gun is special because it is removed if you do
  460. //     not define 'TEST'.
  461. ACTION testgun
  462. {
  463. IFNDEF TEST;
  464.     remove(ME);
  465.     return;
  466. ENDIF;
  467.     MY.__ROTATE = ON;
  468.     MY.__REPEAT = ON;
  469.     MY.__BOB = ON;
  470.     MY.SKILL1 = 50;
  471.     MY.SKILL2 = 20;
  472.     MY.SKILL3 = 20;
  473.     MY._AMMOTYPE = 1.50;
  474.     MY._WEAPONNUMBER = 1;
  475.     MY._BULLETSPEED = -500.05;
  476.     MY._FIRETIME = 2;
  477.     MY._FIREMODE = DAMAGE_SHOOT+FIRE_PARTICLE+HIT_FLASH+0.30;
  478.     gun();
  479. }
  480.  
  481. // Desc: "Logan's Run" type gun, used for testing
  482. //
  483. // uses _WEAPONNUMBER
  484. // uses __SILENT
  485. ACTION logangun
  486. {
  487.     MY.__ROTATE = ON;    // gun rotates before being picked up
  488.     MY.__REPEAT = ON; // repeats (Auto-fire)
  489.     MY.__BOB = ON;      // 'bobs' when the player moves
  490.     MY._OFFS_X = 42;   // x,y,z pos of the gun
  491.     MY._OFFS_Y = 20;
  492.     MY._OFFS_Z = 7;
  493.     MY._AMMOTYPE = 0.0;         // type of ammo '.' rounds in gun
  494.                                     //(0 means no ammo needed)
  495.  
  496.     if(MY._WEAPONNUMBER == 0) { MY._WEAPONNUMBER = 3; }      // weapon number (press 3 to equip)
  497.     MY._BULLETSPEED = 1000.25;    // bulletspeed '.' recoil
  498.     MY._FIRETIME = 5;          // time to cycle (reload)
  499.  
  500.     // SHOOT damage (immediate)
  501.     // + flash at hit point
  502.     // + smoke at hit point
  503.     // + sparks at hit point
  504.     // 50 points of damage per shot
  505.     MY._FIREMODE = DAMAGE_SHOOT + HIT_FLASH + HIT_SMOKE + HIT_SPARKS + FIRE_PARTICLE + 0.50;
  506.     gun();
  507. }
  508.  
  509. // Desc: shotgun type gun
  510. //
  511. // uses _WEAPONNUMBER
  512. // uses __SILENT
  513. ACTION shotgun
  514. {
  515.     MY.__ROTATE = ON;    // gun rotates before being picked up
  516.     MY.__REPEAT = ON; // repeats (Auto-fire)
  517.     MY.__BOB = ON;      // 'bobs' when the player moves
  518.     MY._OFFS_X = 42;   // x,y,z pos of the gun
  519.     MY._OFFS_Y = 20;
  520.     MY._OFFS_Z = 7;
  521.     MY._AMMOTYPE = 5.20;         // type of ammo '.' rounds in gun
  522.                                     //(0 means no ammo needed)
  523.  
  524.     if(MY._WEAPONNUMBER == 0) { MY._WEAPONNUMBER = 5; }    // weapon number (press 5 to equip)
  525.     MY._BULLETSPEED = -300.50;    // bulletspeed '.' recoil
  526.     MY._FIRETIME = 10;          // time to cycle (reload)
  527.  
  528.     // SHOOT damage (immediate)
  529.     // + flash at hit point
  530.     // + smoke at hit point
  531.     // + sparks at hit point
  532.     // 50 points of damage per shot
  533.     MY._FIREMODE = DAMAGE_SHOOT + HIT_SCATTER + HIT_HOLE + 0.15;
  534.     gun();
  535. }
  536.  
  537.  
  538. // Desc: Laser beam type gun
  539. //
  540. // uses _WEAPONNUMBER
  541. // uses __SILENT
  542. ACTION lasergun
  543. {
  544.     MY.__ROTATE = ON;    // gun rotates before being picked up
  545.     MY.__REPEAT = OFF;// repeats (Auto-fire)
  546.     MY.__BOB = ON;      // 'bobs' when the player moves
  547.     MY._OFFS_X = 42;   // x,y,z pos of the gun
  548.     MY._OFFS_Y = 20;
  549.     MY._OFFS_Z = 7;
  550.     MY._AMMOTYPE = 0.0;         // type of ammo '.' rounds in gun
  551.                                     //(0 means no ammo needed)
  552.  
  553.     if( MY._WEAPONNUMBER == 0) { MY._WEAPONNUMBER = 4; }    // weapon number (press 4 to equip)
  554.     MY._BULLETSPEED = 1000.25;    // bulletspeed '.' recoil
  555.     MY._FIRETIME = 5;          // time to cycle (reload)
  556.  
  557.     // SHOOT damage (immediate)
  558.     // + use laser beam
  559.     // + flash at hit point
  560.     // + smoke at hit point
  561.     // + sparks at hit point
  562.     // 50 points of damage per shot
  563.     MY._FIREMODE = DAMAGE_SHOOT + FIRE_LASER + HIT_FLASH + HIT_SMOKE + HIT_SPARKS + 0.50;
  564.     gun();
  565. }
  566.  
  567. // Desc: simple particle gun
  568. //
  569. // uses _WEAPONNUMBER
  570. // uses __SILENT
  571. ACTION sparkgun
  572. {
  573.     MY.__ROTATE = ON;
  574.     MY.__REPEAT = ON;
  575.     MY.__BOB = ON;
  576.     MY._OFFS_X = 50;
  577.     MY._OFFS_Y = 20;
  578.     MY._OFFS_Z = 20;
  579.     MY._AMMOTYPE = 1.50;
  580.     if(MY._WEAPONNUMBER == 0) { MY._WEAPONNUMBER = 1; }
  581.     MY._BULLETSPEED = -500.05;
  582.     MY._FIRETIME = 2;
  583.     MY._FIREMODE = DAMAGE_SHOOT+FIRE_PARTICLE+HIT_FLASH+0.30;
  584.     gun();
  585. }
  586.  
  587. // Desc: Fires orange fireballs
  588. //
  589. // uses _WEAPONNUMBER
  590. // uses __SILENT
  591. ACTION flashgun
  592. {
  593.     MY.__ROTATE = ON;
  594.     MY.__REPEAT = ON;
  595.     MY.__BOB = ON;
  596.     MY.SKILL1 = 42;
  597.     MY.SKILL2 = 20;
  598.     MY.SKILL3 = 7;
  599.     MY._AMMOTYPE = 0.0;//--?? 2.15;
  600.     if(MY._WEAPONNUMBER == 0) { MY._WEAPONNUMBER = 2; }
  601.     MY._BULLETSPEED = 150.05;
  602.     MY._FIRETIME = 5;
  603.     MY._FIREMODE = DAMAGE_EXPLODE+FIRE_BALL+HIT_EXPLO+BULLET_SMOKETRAIL+0.50;
  604.     gun();
  605. }
  606.  
  607. ////////////////////////////////////////////////////////////////////////
  608.  
  609. // Desc: Called from player_move action; player must exist here
  610. function weapon_carry()
  611. {
  612.       if(weapon == NULL || player == NULL) { return; }
  613.     if(person_3rd != 0)
  614.     {
  615.         weapon.INVISIBLE = ON;
  616.  
  617.         player._FIREMODE = weapon._FIRE;  //show the attack animation for the player
  618.     /*    // if firing in 3rd person mode, calculate the player's attack frame
  619.         if(weapon._FIRE > 0)
  620.         {
  621.             temp = (weapon._FIRETIME - weapon._FIRE) / weapon._FIRETIME;
  622.             if(temp < 0) { temp = 0; }
  623.             if(temp > 0.9) { temp = 0.9; }
  624.             player.FRAME = 1 + player._WALKFRAMES + player._RUNFRAMES + 1 + player._ATTACKFRAMES * temp;
  625.         }
  626.     */
  627.     }
  628.     else
  629.     {
  630.         weapon.INVISIBLE = OFF;
  631.         MY_POS.X = weapon.SKILL1;
  632.         MY_POS.Y = -weapon.SKILL2;
  633.         MY_POS.Z = -weapon.SKILL3;
  634.         if(weapon._RECOIL > 0)
  635.         {
  636.             MY_POS.X -= weapon._DISPLACEMENT;
  637.         }
  638.         if(player.__BOB == ON)
  639.         {
  640.             MY_POS.Y += headwave * WEAPON_AMPL;
  641.             MY_POS.X += headwave * WEAPON_AMPL;
  642.             MY_POS.Z -= headwave * WEAPON_AMPL;
  643.         }
  644.  
  645.         _set_pos_ahead_xyz();
  646.         weapon.X = MY_POS.X ;
  647.         weapon.Y = MY_POS.Y;
  648.         weapon.Z = MY_POS.Z;
  649.         weapon.PAN = CAMERA.PAN;
  650.         weapon.TILT = CAMERA.TILT;
  651.         if(weapon._RECOIL < 0)
  652.         {
  653.             weapon.TILT -= weapon._DISPLACEMENT;
  654.         }
  655.     }
  656. }
  657.  
  658.  
  659. ////////////////////////////////////////////////////////////////////////
  660. // Gun select functions
  661. ACTION _gun_select1 { weapon_number = 1; gun_select(); }
  662. ACTION _gun_select2 { weapon_number = 2; gun_select(); }
  663. ACTION _gun_select3 { weapon_number = 3; gun_select(); }
  664. ACTION _gun_select4 { weapon_number = 4; gun_select(); }
  665. ACTION _gun_select5 { weapon_number = 5; gun_select(); }
  666. ACTION _gun_select6 { weapon_number = 6; gun_select(); }
  667. ACTION _gun_select7 { weapon_number = 7; gun_select(); }
  668.  
  669. // Desc: select the 'next' weapon
  670. //
  671. // Mod Date: 05/04/01 DCP
  672. //        Fix endless loop when no weapon exists
  673. //        (Note: this would be cleaner with a do..while loop)
  674. function    gun_select_cycle_up()
  675. {
  676.  
  677.     temp = weapon_number; // save the current weapon_number
  678.     weapon_number += 1;
  679.     while(temp != weapon_number)
  680.     {
  681.         if(weapon_number > kMaxWeapons)
  682.         {
  683.             weapon_number = 0;
  684.             if(temp == 0)  // started with no weapon
  685.             {
  686.                 return(0);
  687.             }
  688.         }
  689.         if(gun_select() != -1)
  690.         {
  691.             return(weapon_number);
  692.         }
  693.         weapon_number += 1;   // try next weapon
  694.     }
  695. }
  696.  
  697. // Desc: select the 'prev' weapon
  698. //
  699. // Mod Date: 05/04/01 DCP
  700. //        Fix endless loop when player has max weapon and no other
  701. //        (Note: this would be cleaner with a do..while loop)
  702. function    gun_select_cycle_down()
  703. {
  704.     temp = weapon_number; // save the current weapon_number
  705.     weapon_number -= 1;
  706.     while(temp != weapon_number)
  707.     {
  708.         if(weapon_number < 0)
  709.         {
  710.             weapon_number = kMaxWeapons;
  711.             if(temp == kMaxWeapons)  // started with max weapon
  712.             {
  713.                 return(kMaxWeapons);
  714.             }
  715.         }
  716.         if(gun_select() != -1)
  717.         {
  718.             return(weapon_number);
  719.         }
  720.         weapon_number -= 1;   // try next weapon
  721.     }
  722. }
  723.  
  724.  
  725.  
  726. // Desc: select/switch weapon
  727. //
  728. //
  729. //    Mod: 07/25/01 DCP
  730. //        Changed to function
  731. function gun_select()
  732. {
  733.     if(weapon != NULL)
  734.     {    // remove old weapon
  735.         weapon.INVISIBLE = ON;
  736.         weapon.PASSABLE = ON;
  737.     }
  738.  
  739.     if(weapon_number == 1) {  ME = weapon1; }
  740.     if(weapon_number == 2) {  ME = weapon2; }
  741.     if(weapon_number == 3) {  ME = weapon3; }
  742.     if(weapon_number == 4) {  ME = weapon4; }
  743.     if(weapon_number == 5) {  ME = weapon5; }
  744.     if(weapon_number == 6) {  ME = weapon6; }
  745.     if(weapon_number == 7) {  ME = weapon7; }
  746.     if(ME == NULL) { return(-1); }
  747.  
  748.     ammo_number = MY._AMMOTYPE;
  749.     MY.INVISIBLE =  OFF;
  750.     MY.PASSABLE = ON;    // prevent collision with obstacles
  751.     MY.NEAR = ON;    // prevent clipping
  752.     weapon = ME;        // I'm the current weapon now
  753.     carry = weapon_carry;
  754.  
  755.     EXCLUSIVE_GLOBAL;
  756.  
  757.     // handle firing
  758.     while(weapon == ME)
  759.     {
  760.         if(weapon_firing && (gun_loaded > 0) && (MY._FIRE <= 0) )
  761.         {
  762.             gun_fire();
  763.         }
  764.  
  765.         if((weapon_firing == 0) && (gun_loaded == 0) && (MY.__REPEAT == OFF))
  766.         {
  767.             gun_loaded = 1;
  768.         }
  769.         wait(1);
  770.     }
  771.     return(weapon_number);
  772. }
  773.  
  774. //////////////////////////////////////////////////////////////////////
  775. // Pickup functions
  776.  
  777.  
  778.  
  779. // Desc: limit ammo to maximum values
  780. //
  781. // Mod:  04/11/01 DCP
  782. //        Added ammo5, ammo6, & ammo7
  783. function _ammo_limit()
  784. {
  785.     if(ammo1 > ammo1.Z) { ammo1 = ammo1.Z; }
  786.     if(ammo2 > ammo2.Z) { ammo2 = ammo2.Z; }
  787.     if(ammo3 > ammo3.Z) { ammo3 = ammo3.Z; }
  788.     if(ammo4 > ammo4.Z) { ammo4 = ammo4.Z; }
  789.     if(ammo5 > ammo5.Z) { ammo5 = ammo5.Z; }
  790.     if(ammo6 > ammo6.Z) { ammo6 = ammo6.Z; }
  791.     if(ammo7 > ammo7.Z) { ammo7 = ammo7.Z; }
  792. }
  793.  
  794. // Desc: handle gun pickup event
  795. //
  796. // Mod:  04/11/01 DCP
  797. //        Turned into function
  798. //        Added ammo5, ammo6, & ammo7
  799. function gun_pickup()
  800. {
  801.     if(EVENT_TYPE == EVENT_SCAN && indicator != _HANDLE) { return; }
  802.     if(EVENT_TYPE == EVENT_PUSH && YOU != player) { return; }
  803.  
  804.     MY.ENABLE_SCAN = OFF;
  805.     MY.ENABLE_CLICK = OFF;
  806.     MY.ENABLE_PUSH = OFF;
  807.  
  808.     if(INT(MY._AMMOTYPE) == 1) { ammo1 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5); }
  809.     if(INT(MY._AMMOTYPE) == 2) { ammo2 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5); }
  810.     if(INT(MY._AMMOTYPE) == 3) { ammo3 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5);    }
  811.     if(INT(MY._AMMOTYPE) == 4) { ammo4 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5);    }
  812.     if(INT(MY._AMMOTYPE) == 5) { ammo5 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5);    }
  813.     if(INT(MY._AMMOTYPE) == 6) { ammo6 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5);    }
  814.     if(INT(MY._AMMOTYPE) == 7) { ammo7 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5);    }
  815.     MY._AMMOTYPE = INT(MY._AMMOTYPE);    // ammo type
  816.     _ammo_limit();
  817.  
  818.     weapon_number = MY._WEAPONNUMBER;
  819.     if(weapon_number == 1) {  weapon1 = ME; weapon_1 = 1;  ON_1 = _gun_select1;  msg.STRING = got_gun1_str; }
  820.     if(weapon_number == 2) {  weapon2 = ME; weapon_2 = 1;  ON_2 = _gun_select2;  msg.STRING = got_gun2_str; }
  821.     if(weapon_number == 3) {  weapon3 = ME; weapon_3 = 1;  ON_3 = _gun_select3;  msg.STRING = got_gun3_str; }
  822.     if(weapon_number == 4) {  weapon4 = ME; weapon_4 = 1;  ON_4 = _gun_select4;  msg.STRING = got_gun4_str; }
  823.     if(weapon_number == 5) {  weapon5 = ME; weapon_5 = 1;  ON_5 = _gun_select5;  msg.STRING = got_gun5_str; }
  824.     if(weapon_number == 6) {  weapon6 = ME; weapon_6 = 1;  ON_6 = _gun_select6;  msg.STRING = got_gun6_str; }
  825.     if(weapon_number == 7) {  weapon7 = ME; weapon_7 = 1;  ON_7 = _gun_select7;  msg.STRING = got_gun7_str; }
  826.  
  827.     if(MY.__SILENT != ON) { show_message(); }
  828.     gun_select();
  829. }
  830.  
  831.  
  832. // Desc: handle ammo pickup event
  833. // Mod:  04/11/01 DCP
  834. //        Added ammo5, ammo6, & ammo7
  835. function ammo_pickup()
  836. {
  837.     if(EVENT_TYPE == EVENT_SCAN && indicator != _HANDLE) { return; }
  838.     if(EVENT_TYPE == EVENT_PUSH && YOU != player) { return; }
  839.  
  840.     if(MY._AMMOTYPE == 1) { ammo1 += MY._PACKAMOUNT;  msg.STRING = got_ammo1_str; }
  841.     if(MY._AMMOTYPE == 2) { ammo2 += MY._PACKAMOUNT;  msg.STRING = got_ammo2_str; }
  842.     if(MY._AMMOTYPE == 3) { ammo3 += MY._PACKAMOUNT;  msg.STRING = got_ammo3_str; }
  843.     if(MY._AMMOTYPE == 4) { ammo4 += MY._PACKAMOUNT;  msg.STRING = got_ammo4_str; }
  844.     if(MY._AMMOTYPE == 5) { ammo5 += MY._PACKAMOUNT;  msg.STRING = got_ammo5_str; }
  845.     if(MY._AMMOTYPE == 6) { ammo6 += MY._PACKAMOUNT;  msg.STRING = got_ammo6_str; }
  846.     if(MY._AMMOTYPE == 7) { ammo7 += MY._PACKAMOUNT;  msg.STRING = got_ammo7_str; }
  847.     if(MY.__SILENT != ON) { show_message(); }
  848.     _ammo_limit();
  849.     PLAY_SOUND ammo_fetch,50;
  850.  
  851.  
  852.     if(MY.__SILENT != ON)
  853.     {
  854.         // hide item..
  855.         MY.EVENT = NULL;
  856.         MY.PASSABLE = ON;
  857.         MY.INVISIBLE = ON;
  858.  
  859.         waitt(MSG_TICKS);    // wait for message to vanish
  860.     }
  861.  
  862.     remove(ME);
  863. }
  864.  
  865.  
  866. // Desc: ammo pack entity
  867. //
  868. // Mod:  04/11/01 DCP
  869. //        Added ammo5, ammo6, & ammo7
  870. //
  871. // uses _AMMOTYPE, _PACKAMOUNT
  872. // uses __ROTATE, __SILENT
  873. ACTION ammopac
  874. {
  875.     // default ammo type is 1
  876.     if(MY._AMMOTYPE == 0) { MY._AMMOTYPE = 1; }
  877.  
  878.     // default ammo amount is a quarter of ammo maximum
  879.     if(MY._PACKAMOUNT == 0)
  880.     {
  881.         if(MY._AMMOTYPE == 1) { MY._PACKAMOUNT = ammo1.Z * 0.25; }
  882.         if(MY._AMMOTYPE == 2) { MY._PACKAMOUNT = ammo2.Z * 0.25; }
  883.         if(MY._AMMOTYPE == 3) { MY._PACKAMOUNT = ammo3.Z * 0.25; }
  884.         if(MY._AMMOTYPE == 4) { MY._PACKAMOUNT = ammo4.Z * 0.25; }
  885.         if(MY._AMMOTYPE == 5) { MY._PACKAMOUNT = ammo5.Z * 0.25; }
  886.         if(MY._AMMOTYPE == 6) { MY._PACKAMOUNT = ammo6.Z * 0.25; }
  887.         if(MY._AMMOTYPE == 7) { MY._PACKAMOUNT = ammo7.Z * 0.25; }
  888.     }
  889.  
  890.     MY.EVENT = ammo_pickup;
  891.     item_pickup();
  892. }
  893.  
  894. // Desc: handle medipac event
  895. function medi_pickup()
  896. {
  897.     if(EVENT_TYPE == EVENT_SCAN && indicator != _HANDLE) { return; }
  898.     if(EVENT_TYPE == EVENT_PUSH && YOU != player) { return; }
  899.  
  900.     if(YOU == NULL) {  YOU = player; }
  901.     if(YOU == NULL) { return; }
  902.  
  903.     YOUR._HEALTH += MY.SKILL5;
  904.     if(YOUR._HEALTH > 100) { YOUR._HEALTH = 100; }  // health max at 100%
  905.  
  906.     PLAY_SOUND health_fetch,50;
  907.     msg.STRING = got_medi_str;
  908.  
  909.     if(MY.__SILENT != ON) { show_message(); }
  910.     remove(ME);
  911. }
  912.  
  913. // Desc: medipac entity
  914. //
  915. // uses _PACKAMOUNT
  916. // uses __ROTATE, __SILENT
  917. ACTION medipac
  918. {
  919.     if(MY._PACKAMOUNT == 0) { MY._PACKAMOUNT = 25; }
  920.     MY.EVENT = medi_pickup;
  921.     item_pickup();
  922. }
  923.  
  924.  
  925. // Desc: restore a gun already owned by the player (from a previous level)
  926. //
  927. // Note: keep the gun in the level
  928. //
  929. // Mod Date: 02/13/02 DCP
  930. //        Added 'gun_loaded = 1' to reload repeating guns.
  931. function gun_restore()
  932. {
  933.     // weapon was already picked up by the player
  934.     MY._AMMOTYPE = INT(MY._AMMOTYPE);    // happens on pickup
  935.  
  936.     MY.INVISIBLE = ON;
  937.     MY.PASSABLE = ON;
  938.     MY.ENABLE_SCAN = OFF;
  939.     MY.ENABLE_CLICK = OFF;
  940.     MY.ENABLE_PUSH = OFF;
  941.     MY.EVENT = NULL;
  942.     // Was it the last weapon the player carried?
  943.     if(weapon_number == MY._WEAPONNUMBER) { gun_select(); }
  944.     if(MY.__REPEAT == ON)
  945.     {
  946.         //reload repeating guns (in case they were in 'mid-fire')
  947.         wait(1);            // allow the gun to move 'in place'
  948.         gun_loaded = 1;   // reload
  949.     }
  950. }
  951.  
  952. // Desc: set up a gun
  953. //
  954. // Mod: 12/18/01 DCP
  955. //        Moved _OFFS_FLASH (made it user definable)
  956. //        Added default _AMMOTYPE
  957. //
  958. // Mod: 02/13/02 DCP
  959. //     Removed default _AMMOTYPE (if _AMMOTYPE = 0, gun has unlimited ammo)
  960. //
  961. // uses _OFFS_X, _OFFS_Y, _OFFS_Z, _GUN_SOURCE_X, _GUN_SOURCE_Y, _GUN_SOURCE_Z
  962. // uses _OFFS_FLASH, _WEAPONNUMBER, _FIREMODE, _BULLETSPEED, _AMMOTYPE, _FIRETIME
  963. // uses __ROTATE, __SILENT, __REPEAT, __BOB
  964. ACTION gun
  965. {
  966.     // set the weapon camera offset (if one is not already defined)
  967.     if(MY._OFFS_X == 0)
  968.     {
  969.         MY._OFFS_X = 50;
  970.         MY._OFFS_Y = 20;
  971.         MY._OFFS_Z = 20;
  972.     }
  973.  
  974.  
  975.     if(MY._OFFS_FLASH == 0)
  976.     {
  977.         MY._OFFS_FLASH = MY.MAX_X + 1;     // Muzzle flash offset
  978.     }
  979.  
  980.     // set the weapon source offset (if one is not already defined)
  981.     if(MY._GUN_SOURCE_X == 0)
  982.     {
  983.         MY._GUN_SOURCE_X = MY._OFFS_X + MY._OFFS_FLASH;
  984.         MY._GUN_SOURCE_Y = -MY._OFFS_Y;
  985.         MY._GUN_SOURCE_Z = -MY._OFFS_Z;
  986.     }
  987.  
  988.     // make sure we have a valid _WEAPONNUMBER
  989.     if(MY._WEAPONNUMBER <= 0 || MY._WEAPONNUMBER > 7)
  990.     { MY._WEAPONNUMBER = 1; }
  991.  
  992.     // set damage
  993.     MY._DAMAGE = FRC(MY._FIREMODE) * 100;
  994.      if(MY._DAMAGE == 0)
  995.     { MY._DAMAGE = 20; } // default to 20 damage
  996.  
  997.     // set firemode
  998.     MY._FIREMODE = INT(MY._FIREMODE);
  999.     if(MY._FIREMODE == 0)
  1000.     { MY._FIREMODE = DAMAGE_SHOOT+FIRE_PARTICLE+HIT_FLASH; }   // default to
  1001.  
  1002.     // set recoil (up or back)
  1003.     MY._RECOIL = FRC(MY._BULLETSPEED) * 100;
  1004.  
  1005.     // set bullet speed
  1006.     MY._BULLETSPEED = ABS(MY._BULLETSPEED);
  1007.     if(MY._BULLETSPEED < 1)
  1008.     { MY._BULLETSPEED = 200; }   // default to 200
  1009.  
  1010. /* removed 021302
  1011.     // make sure we have an ammotype
  1012.     if(MY._AMMOTYPE == 0)
  1013.     { MY._AMMOTYPE = 1; } // default ammotype
  1014. */
  1015.  
  1016.     MY.EVENT = gun_pickup;
  1017.     item_pickup();
  1018.  
  1019.     // check whether this gun was picked up before in another level,
  1020.     // and has to be re-created for this level
  1021.     if(MY._WEAPONNUMBER == 1 && weapon_1 == 1 && weapon1 == NULL)
  1022.     { weapon1 = ME; gun_restore(); return; }
  1023.     if(MY._WEAPONNUMBER == 2 && weapon_2 == 1 && weapon2 == NULL)
  1024.     { weapon2 = ME; gun_restore(); return; }
  1025.     if(MY._WEAPONNUMBER == 3 && weapon_3 == 1 && weapon3 == NULL)
  1026.     { weapon3 = ME; gun_restore(); return; }
  1027.     if(MY._WEAPONNUMBER == 4 && weapon_4 == 1 && weapon4 == NULL)
  1028.     { weapon4 = ME; gun_restore(); return; }
  1029.     if(MY._WEAPONNUMBER == 5 && weapon_5 == 1 && weapon5 == NULL)
  1030.     { weapon5 = ME; gun_restore(); return; }
  1031.     if(MY._WEAPONNUMBER == 6 && weapon_6 == 1 && weapon6 == NULL)
  1032.     { weapon6 = ME; gun_restore(); return; }
  1033.     if(MY._WEAPONNUMBER == 7 && weapon_7 == 1 && weapon7 == NULL)
  1034.     { weapon7 = ME; gun_restore(); return; }
  1035. }
  1036.  
  1037.  
  1038.  
  1039. // Desc: start the player with this gun
  1040. // Use:  CREATE(<WAFFE1.MDL>,nullskill,startgun1);
  1041. //
  1042. // Mod:  04/17/01 DCP
  1043. //        Added _GUN_SOURCE_X/Y/Z values
  1044. function    startgun1()
  1045. {
  1046.     // NOTE: these are the stats you should adjust in your 'startgun'
  1047.     MY.__REPEAT = ON;
  1048.     MY.__BOB = ON;
  1049.     MY._OFFS_X = 50;
  1050.     MY._OFFS_Y = 20;
  1051.     MY._OFFS_Z = 20;
  1052.  
  1053.     MY._GUN_SOURCE_X = -1;
  1054.     MY._GUN_SOURCE_Y = 2;
  1055.     MY._GUN_SOURCE_Z = -1;
  1056.  
  1057.     MY._AMMOTYPE = 0.0;            // type 0 with unlimited ammo
  1058.     MY._WEAPONNUMBER = 1;          // weapon 1
  1059.     MY._BULLETSPEED = -500.05;     // speed/range . 5 recoil
  1060.     MY._FIRETIME = 2;
  1061.     MY._FIREMODE = DAMAGE_SHOOT+FIRE_PARTICLE+HIT_SPARKS+HIT_FLASH+0.30+GUNFX_BRASS;
  1062.  
  1063.     // Always end with a call to 'gun_givePlayer'
  1064.     gun_givePlayer();
  1065. }
  1066.  
  1067. // Desc: init a gun, give it to the player, and select it
  1068. // Note: see the Action 'startgun1' to see how to use this function
  1069. function    gun_givePlayer()
  1070. {
  1071.     gun();   // init the gun
  1072.  
  1073.     MY.ENABLE_SCAN = OFF;
  1074.     MY.ENABLE_CLICK = OFF;
  1075.     MY.ENABLE_PUSH = OFF;
  1076.  
  1077.     if(INT(MY._AMMOTYPE) == 1) { ammo1 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5); }
  1078.     if(INT(MY._AMMOTYPE) == 2) { ammo2 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5); }
  1079.     if(INT(MY._AMMOTYPE) == 3) { ammo3 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5);    }
  1080.     if(INT(MY._AMMOTYPE) == 4) { ammo4 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5);    }
  1081.     if(INT(MY._AMMOTYPE) == 5) { ammo5 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5);    }
  1082.     if(INT(MY._AMMOTYPE) == 6) { ammo6 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5);    }
  1083.     if(INT(MY._AMMOTYPE) == 7) { ammo7 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5);    }
  1084.     MY._AMMOTYPE = INT(MY._AMMOTYPE);    // ammo type
  1085.     _ammo_limit();
  1086.  
  1087.     weapon_number = MY._WEAPONNUMBER;
  1088.     if(weapon_number == 1) {  weapon1 = ME; weapon_1 = 1;  ON_1 = _gun_select1;  msg.STRING = got_gun1_str; }
  1089.     if(weapon_number == 2) {  weapon2 = ME; weapon_2 = 1;  ON_2 = _gun_select2;  msg.STRING = got_gun2_str; }
  1090.     if(weapon_number == 3) {  weapon3 = ME; weapon_3 = 1;  ON_3 = _gun_select3;  msg.STRING = got_gun3_str; }
  1091.     if(weapon_number == 4) {  weapon4 = ME; weapon_4 = 1;  ON_4 = _gun_select4;  msg.STRING = got_gun4_str; }
  1092.     if(weapon_number == 5) {  weapon5 = ME; weapon_5 = 1;  ON_5 = _gun_select5;  msg.STRING = got_gun5_str; }
  1093.     if(weapon_number == 6) {  weapon6 = ME; weapon_6 = 1;  ON_6 = _gun_select6;  msg.STRING = got_gun6_str; }
  1094.     if(weapon_number == 7) {  weapon7 = ME; weapon_7 = 1;  ON_7 = _gun_select7;  msg.STRING = got_gun7_str; }
  1095.  
  1096.     if(MY.__SILENT != ON) { show_message(); }
  1097.     gun_select();
  1098. }
  1099.  
  1100.  
  1101.  
  1102. //////////////////////////////////////////////////////////////////////
  1103.  
  1104. // Desc: fire weapon
  1105. function weapon_fire()
  1106. {
  1107.     weapon_firing = 1;
  1108.      while(KEY_CTRL || MOUSE_LEFT) { wait(1); }
  1109.     weapon_firing = 0;
  1110. }
  1111.  
  1112. // Desc: deselect weapon
  1113. function weapon_remove()
  1114. {
  1115.     if(weapon != NULL)
  1116.     {
  1117.         weapon.INVISIBLE = ON;
  1118.         weapon = NULL;
  1119.         weapon_number = 0;
  1120.     }
  1121. }
  1122.  
  1123. // Desc: put weapons and ammo to inital state
  1124. //
  1125. function weapon_init()
  1126. {
  1127.     weapon_remove();
  1128.     ammo1 = 0;
  1129.     ammo2 = 0;
  1130.     ammo3 = 0;
  1131.     ammo4 = 0;
  1132.     ammo5 = 0;
  1133.     ammo6 = 0;
  1134.     ammo7 = 0;
  1135.     weapon_1 = 0;
  1136.     weapon_2 = 0;
  1137.     weapon_3 = 0;
  1138.     weapon_4 = 0;
  1139.     weapon_5 = 0;
  1140.     weapon_6 = 0;
  1141.     weapon_7 = 0;
  1142.     weapon_number = 0;
  1143. }
  1144.  
  1145. //////////////////////////////////////////////////////////////////////
  1146.  
  1147. string    anim_gun_shot = "shot";     // gun animation string
  1148.                                                 // used in 'gun_animate()'
  1149.  
  1150. // Desc: animate the gun model using _FIRETIME and _FIRE
  1151. //
  1152. // Mod: 07/25/01    DCP
  1153. //        Created
  1154. function    gun_animate()
  1155. {
  1156.     while(MY._FIRE > 0)
  1157.     {
  1158.         // play one cycle
  1159.         temp = ((MY._FIRETIME - MY._FIRE)/ MY._FIRETIME) * 100;
  1160.         ent_cycle(anim_gun_shot,temp);
  1161.         wait(1);
  1162.     }
  1163.     ent_frame(anim_gun_shot,0);     // return to base frame
  1164. }
  1165.  
  1166.  
  1167. // Desc:  Handle the player firing the gun
  1168. //
  1169. // Mod:  04/11/01 DCP
  1170. //        Added ammo5, ammo6, & ammo7
  1171. //
  1172. // Mod:  04/17/01 DCP
  1173. //        Make player passable before calling 'gun_shot' (restore afterwords)
  1174. //
  1175. // Mod:  04/18/01 DCP
  1176. //        Calculate 'gun_source' here now. Set 'gun_source[3] = 9' so gun_shot
  1177. //    knows to use the 'gun_source' vector for traces.
  1178. //         Modified 3rd person 'gun_source', 'gun_muzzle', & 'gun_target' calculation
  1179. //    (no longer depends on cammera location)
  1180. //
  1181. // Mod:  04/18/01 DCP
  1182. //        Replaced goto no_ammo with _gun_fire_no_ammo();
  1183. //
  1184. // Mod: 07/25/01 DCP
  1185. //    Added check for gun animation (calls "gun_animate()").
  1186. function gun_fire()
  1187. {
  1188.     // check to make sure we have ammo
  1189.     // if so, reduce ammo# count by one
  1190.     // else got 'no_ammo'
  1191.     if(MY._AMMOTYPE == 1)
  1192.     {
  1193.         if(ammo1 > 0) { ammo1 -= 1; }
  1194.         else{ _gun_fire_no_ammo(); return; }
  1195.     }
  1196.     if(MY._AMMOTYPE == 2)
  1197.     {
  1198.         if(ammo2 > 0) { ammo2 -= 1; }
  1199.         else{ _gun_fire_no_ammo(); return; }
  1200.     }
  1201.     if(MY._AMMOTYPE == 3)
  1202.     {
  1203.         if(ammo3 > 0) { ammo3 -= 1; }
  1204.         else{ _gun_fire_no_ammo(); return; }
  1205.     }
  1206.     if(MY._AMMOTYPE == 4)
  1207.     {
  1208.         if(ammo4 > 0) { ammo4 -= 1; }
  1209.         else{ _gun_fire_no_ammo(); return; }
  1210.     }
  1211.     if(MY._AMMOTYPE == 5)
  1212.     {
  1213.         if(ammo5 > 0) { ammo5 -= 1; }
  1214.         else{ _gun_fire_no_ammo(); return; }
  1215.     }
  1216.     if(MY._AMMOTYPE == 6)
  1217.     {
  1218.         if(ammo6 > 0) { ammo6 -= 1; }
  1219.         else{ _gun_fire_no_ammo(); return; }
  1220.     }
  1221.     if(MY._AMMOTYPE == 7)
  1222.     {
  1223.         if(ammo7 > 0) { ammo7 -= 1; }
  1224.         else{ _gun_fire_no_ammo(); return; }
  1225.     }
  1226.  
  1227.    gun_loaded = 0;
  1228.  
  1229.     // place muzzle flash
  1230.     if((person_3rd != 0) && (player != NULL))
  1231.     {
  1232.         MY_POS.X = player.MAX_X - player.MIN_X;
  1233.         MY_POS.Y = 0;
  1234.         MY_POS.Z = 0;
  1235.          vec_rotate(MY_POS,player.PAN);
  1236.         MY_POS.X += player.X;
  1237.          MY_POS.Y += player.Y;
  1238.          MY_POS.Z += player.Z;
  1239.     }
  1240.     else
  1241.     {
  1242.         MY_POS.X = MY.SKILL1 + MY._OFFS_FLASH;
  1243.         MY_POS.Y = -MY.SKILL2;
  1244.         MY_POS.Z = -MY.SKILL3;
  1245.         _set_pos_ahead_xyz();
  1246.     }
  1247.     vec_set(gun_muzzle.X,MY_POS.X);
  1248.     create(muzzle_flash,gun_muzzle,_flashup);
  1249.  
  1250.     // calculate target
  1251.     MY_POS.X = MY._BULLETSPEED;
  1252.     if((person_3rd != 0) && (player != NULL))
  1253.     {
  1254.         MY_POS.Y = 0;
  1255.         MY_POS.Z = 0;
  1256.          vec_rotate(MY_POS,player.PAN);
  1257.         MY_POS.X += player.X;
  1258.          MY_POS.Y += player.Y;
  1259.          MY_POS.Z += player.Z;
  1260.     }
  1261.     else
  1262.     {
  1263.         MY_POS.Y = -MY.SKILL2;
  1264.         MY_POS.Z = -MY.SKILL3;
  1265.         _set_pos_ahead_xyz();
  1266.     }
  1267.     vec_set(gun_target.X,MY_POS.X);
  1268.  
  1269.     wait(1); // allow muzzle_flash to become passable (so bullet does not hit it!)
  1270.  
  1271.  
  1272.     // place gun trace source back (DCP fix 04/13/01)
  1273.     if((person_3rd != 0) && (player != NULL))
  1274.     {
  1275.         MY_POS.X = (player.MAX_X - player.MIN_X);
  1276.         MY_POS.Y = 0;
  1277.         MY_POS.Z = 0;
  1278.  
  1279.          vec_rotate(MY_POS,player.PAN);
  1280.         MY_POS.X += player.X;
  1281.          MY_POS.Y += player.Y;
  1282.          MY_POS.Z += player.Z;
  1283.     }
  1284.     else
  1285.     {
  1286.         MY_POS.X = MY._GUN_SOURCE_X;//?-(player.MAX_X - player.MIN_X)/2; //--MY.SKILL1 + MY._OFFS_FLASH;
  1287.         MY_POS.Y = MY._GUN_SOURCE_Y;//? -MY.SKILL2;
  1288.         MY_POS.Z = MY._GUN_SOURCE_Z;//?-MY.SKILL3;
  1289.           _set_pos_ahead_xyz();
  1290.     }
  1291.     vec_set(gun_source.X,MY_POS.X);
  1292.     gun_source[3] = 9;             // mark this as 'player fired'
  1293.  
  1294.    // emit a bullet or particle
  1295.     shot_speed.X = (gun_target.X - gun_source.X);
  1296.     shot_speed.Y = (gun_target.Y - gun_source.Y);
  1297.     shot_speed.Z = (gun_target.Z - gun_source.Z);
  1298.  
  1299.     damage = MY._DAMAGE;
  1300.     fire_mode = MY._FIREMODE;
  1301.  
  1302.     // if player is not already passable
  1303.     if(player.passable == OFF)
  1304.     {
  1305.         player.passable = ON;   // make it so the gun doesn't hit the player
  1306.         gun_shot();                   // fire the shot
  1307.          player.passable = OFF;
  1308.     }
  1309.     else
  1310.     {
  1311.         gun_shot();
  1312.     }
  1313.  
  1314.     MY._FIRE = MY._FIRETIME;
  1315.  
  1316.     // animate gun?
  1317.     if((fire_mode & GUNFX_ANIMATE) != 0)
  1318.     {
  1319.          gun_animate(); // animate gun cycle
  1320.     }
  1321.  
  1322.     MY._DISPLACEMENT = MY._RECOIL;
  1323.     while(MY._FIRE > 0)
  1324.     {
  1325.         wait(1);
  1326.          // rock back into place from recoil
  1327.         MY._DISPLACEMENT *= 0.6;
  1328.         MY._FIRE -= TIME;
  1329.     }
  1330.     MY._DISPLACEMENT = 0 ;
  1331.     MY._FIRE = 0 ;
  1332.  
  1333.     if(MY.__REPEAT == ON) { gun_loaded = 1;}
  1334. }
  1335.  
  1336. // Desc: handle gun_fire's no ammo case
  1337. //        (play 'gun_click' noise at half volume)
  1338. //
  1339. // Note: entity (ME) must be valid
  1340. //
  1341. // Mod 04/19/01 DCP
  1342. //        Created
  1343. function _gun_fire_no_ammo()
  1344. {
  1345.     PLAY_ENTSOUND(ME,gun_click,50);
  1346. }
  1347.  
  1348. var    _gun_shot_temp[3];     // 'local' temp vector
  1349. var    _gun_shot_sCount;      // 'local' counter
  1350. var    scatter_number = 6;       // number of SCATTER rounds
  1351. DEFINE    SCATTER_RAND, 160;      // SCATTER width
  1352. DEFINE    SCATTER_HALF_RAND, 80;
  1353.  
  1354. // Desc: select and handle shot type using 'fire_mode'
  1355. //
  1356. // needs gun_muzzle,shot_speed,damage,fire_mode
  1357. //
  1358. function gun_shot()
  1359. {
  1360.     // select and handle shot type using 'fire_mode'
  1361.  
  1362.     // particle trail shot (line of particles)
  1363.     if((fire_mode & MODE_FIRE) == FIRE_PARTICLE)
  1364.     {
  1365.         vec_set(p,gun_muzzle);
  1366.         vec_set(p2,gun_target);
  1367.         particle_line();
  1368.     }
  1369.  
  1370.     // single particle
  1371.     if((fire_mode & MODE_FIRE) == FIRE_DPARTICLE)
  1372.     { emit(1,gun_muzzle,particle_shot); }
  1373.  
  1374.     // fireball
  1375.     if((fire_mode & MODE_FIRE) == FIRE_BALL)
  1376.     { create(fireball,gun_muzzle,bullet_shot); }
  1377.  
  1378.     // rocket model
  1379.     if((fire_mode & MODE_FIRE) == FIRE_ROCKET)
  1380.     { create(<rocket.mdl>,gun_muzzle,rocket_launch); }
  1381.  
  1382.     // eject brass?
  1383.     if((fire_mode & GUNFX_BRASS) != 0)
  1384.     {
  1385.          emit(1,gun_muzzle,particle_gunBrass); // emit brass
  1386.     }
  1387.  
  1388.  
  1389.     // bullet damage is done with a trace
  1390.     if((fire_mode & MODE_DAMAGE) == DAMAGE_SHOOT)
  1391.     {
  1392.         // set gun_target
  1393.         gun_target.X = 2*shot_speed.X + gun_muzzle.X;
  1394.         gun_target.Y = 2*shot_speed.Y + gun_muzzle.Y;
  1395.         gun_target.Z = 2*shot_speed.Z + gun_muzzle.Z;
  1396.  
  1397.         if((fire_mode & HIT_SCATTER) != 0)    // scatter gun?
  1398.         {
  1399.             vec_set(_gun_shot_temp.X, gun_target.X);    // save base gun_target
  1400.  
  1401.             _gun_shot_sCount = 0;
  1402.             while(_gun_shot_sCount < scatter_number)
  1403.             {
  1404.                 // offset each shot by a random amount
  1405.                 gun_target.X = _gun_shot_temp.X + (Random(SCATTER_RAND)-SCATTER_HALF_RAND);
  1406.                 gun_target.Y = _gun_shot_temp.Y + (Random(SCATTER_RAND)-SCATTER_HALF_RAND);
  1407.                 gun_target.Z = _gun_shot_temp.Z + (Random(SCATTER_RAND)-SCATTER_HALF_RAND);
  1408.                 _gun_shot_damage_shoot();
  1409.                 _gun_shot_sCount += 1;
  1410.             }
  1411.             vec_set(gun_target.X, _gun_shot_temp.X);    // restore  gun_target
  1412.          }
  1413.         else
  1414.         {
  1415.             // fire one shot
  1416.              _gun_shot_damage_shoot();
  1417.         }
  1418.  
  1419.     }
  1420. }
  1421.  
  1422.  
  1423. // Desc: handle DAMAGE_SHOOT shots from function 'gun_shot'
  1424. //
  1425. // Note: helper function for gun_shot
  1426. //
  1427. // Mod 04/20/01 DCP
  1428. //        Created
  1429. function _gun_shot_damage_shoot()
  1430. {
  1431.  
  1432.         indicator = _GUNFIRE;    // indicator for the entity that was hit
  1433.         trace_mode = IGNORE_ME + IGNORE_PASSABLE + ACTIVATE_SHOOT;
  1434.         if(gun_source[3] == 9)     // player firing?
  1435.         {
  1436.             // use gun_source
  1437. //--CREATE(<ARROW.PCX>,gun_source,_test_arrow);   // used to test gun_source
  1438.              RESULT = trace(gun_source,gun_target);
  1439.             gun_source[3] = 0;    // reset value
  1440.         }
  1441.         else
  1442.         {
  1443.             // use gun_muzzle
  1444. //--CREATE(<ARROW.PCX>,gun_muzzle,_test_arrow);   // used to test gun_muzzle
  1445.              RESULT = trace(gun_muzzle,gun_target);
  1446.         }
  1447.  
  1448.         if((fire_mode & MODE_FIRE) == FIRE_LASER)
  1449.         {
  1450.             weaponTmpSyn = YOU;  // save YOU value (used for bullet holes)
  1451.             create(<lbeam.mdl>,gun_muzzle,laser_fire);  // uses TARGET & RESULT
  1452.             YOU = weaponTmpSyn;    // restore YOU value
  1453.         }
  1454.  
  1455.        if(RESULT > 0)
  1456.         { // hit something?
  1457.             _hit_point_effect();    // send fire_mode and TARGET
  1458.         }
  1459. }
  1460.  
  1461. ///////////////////////////////////////////////////////////////////////
  1462. // Desc: hit flash
  1463. //
  1464. function _blowup()
  1465. {
  1466.     MY.SCALE_X = 2;
  1467.     MY.SCALE_Y = 2;
  1468.     vec_scale(MY.SCALE_X,actor_scale);
  1469.  
  1470.     MY.PASSABLE = ON;
  1471.     MY.FACING = ON;
  1472.     MY.NEAR = ON;
  1473.     MY.FLARE = ON;
  1474.     MY.AMBIENT = 100;
  1475.     MY.LIGHTRED = light_flash.RED;
  1476.     MY.LIGHTGREEN = light_flash.GREEN;
  1477.     MY.LIGHTBLUE = light_flash.BLUE;
  1478.     MY.LIGHTRANGE = 64;
  1479.     wait(1);
  1480.     PLAY_ENTSOUND ME,hit_wham,300;
  1481.     remove(ME);
  1482. }
  1483.  
  1484. // Desc: muzzle flash
  1485. //
  1486. function _flashup()
  1487. {
  1488.     MY.SCALE_X = 2;
  1489.     MY.SCALE_Y = 2;
  1490.     vec_scale(MY.SCALE_X,actor_scale);
  1491.  
  1492.     MY.PASSABLE = ON;
  1493.     // Set flare only in D3D mode
  1494.     if(VIDEO_MODE > 8) { MY.FLARE = ON; }
  1495.     else{ MY.TRANSPARENT = ON; }
  1496.  
  1497.     MY.FACING = ON;
  1498.     MY.AMBIENT = 100;
  1499.     MY.LIGHTRED = light_muzzle.RED;
  1500.     MY.LIGHTGREEN = light_muzzle.GREEN;
  1501.     MY.LIGHTBLUE = light_muzzle.BLUE;
  1502.     MY.LIGHTRANGE = 100;
  1503.     wait(1);
  1504.     PLAY_SOUND gun_wham,50;
  1505.     remove(ME);
  1506. }
  1507.  
  1508.  
  1509. function _fireball_event()
  1510. {
  1511.     // check for all collision events
  1512.     if(EVENT_TYPE == EVENT_BLOCK
  1513.         || EVENT_TYPE == EVENT_ENTITY
  1514.         || EVENT_TYPE == EVENT_STUCK
  1515.         || EVENT_TYPE == EVENT_IMPACT
  1516.         || EVENT_TYPE == EVENT_PUSH)
  1517.     {
  1518.         wait(1);// added to avoid Dangerous instruction
  1519.         EXCLUSIVE_ENTITY;    // terminate other actions, to stop moving
  1520.         MY.EVENT = NULL;
  1521.  
  1522.          range = MY._DAMAGE * 3;
  1523.         damage = MY._DAMAGE;
  1524.          temp.PAN = 360;
  1525.         temp.TILT = 180;
  1526.         temp.Z = range;
  1527.         indicator = _EXPLODE;    // must always be set before scanning
  1528.         scan(MY.POS,MY_ANGLE,temp);
  1529.  
  1530.         morph BULLET_EXPLO,ME;
  1531.         MY._DIEFRAMES = EXPLO_FRAMES;
  1532.         actor_explode();
  1533.     }
  1534. }
  1535.  
  1536.  
  1537. // Desc: event attached to rocket
  1538. //            Explode the rocket.
  1539. //
  1540. function _rocket_event()
  1541. {
  1542.     EXCLUSIVE_ENTITY;    // terminate other actions, to stop moving
  1543.     MY.EVENT = NULL;
  1544.     MY.SKILL9 = -1;   // stop movement
  1545.  
  1546.       // Explode
  1547.     morph <explo+7.pcx>, ME;
  1548.     MY.AMBIENT = 100;
  1549.     MY.FACING = ON;
  1550.     MY.NEAR = ON;
  1551.       MY.FLARE = ON;
  1552.  
  1553.     MY.PASSABLE =  ON;
  1554.     MY.AMBIENT = 100;
  1555.     MY.LIGHTRED = light_flash.RED;
  1556.     MY.LIGHTGREEN = light_flash.GREEN;
  1557.     MY.LIGHTBLUE = light_flash.BLUE;
  1558.     MY.LIGHTRANGE = 64;
  1559.     wait(1);
  1560.  
  1561.     play_entsound ME,hit_wham,300;
  1562.     while(MY.CYCLE <= 7)
  1563.     {
  1564.         MY.CYCLE += TIME;
  1565.         waitt(1);
  1566.     }
  1567.  
  1568.     // Apply damage
  1569.     range = MY._DAMAGE * 6;
  1570.     damage = MY._DAMAGE;
  1571.      temp.PAN = 360;
  1572.     temp.TILT = 360;
  1573.     temp.Z = range;
  1574.     indicator = _EXPLODE;    // must always be set before scanning
  1575.     scan(MY.POS,MY_ANGLE,temp);
  1576.  
  1577.     remove(ME);
  1578. }
  1579.  
  1580.  
  1581.  
  1582.  
  1583. // runs a bullet; requires shot_speed, damage, fire_mode to be set
  1584. //
  1585. // Note: called from gun_shot
  1586. //
  1587. // Mod Date: 05/17/01 DCP
  1588. //            Changed to function.
  1589. //
  1590. // Mod Date: 06/08/01 DCP
  1591. //            Replaced move() with ent_move()
  1592. //
  1593. function bullet_shot()
  1594. {
  1595.     vec_scale(MY.SCALE_X,actor_scale);    // use actor_scale
  1596.  
  1597.     MY.ENABLE_BLOCK = ON;
  1598.     MY.ENABLE_ENTITY = ON;
  1599.     MY.ENABLE_STUCK = ON;
  1600.     MY.ENABLE_IMPACT = ON;
  1601.     MY.ENABLE_PUSH = ON;
  1602.     MY.EVENT = _fireball_event;
  1603.  
  1604.     MY.FACING = ON;    // in case of fireball
  1605.  
  1606.     MY.LIGHTRED = light_bullet.RED;
  1607.     MY.LIGHTGREEN = light_bullet.GREEN;
  1608.     MY.LIGHTBLUE = light_bullet.BLUE;
  1609.     MY.LIGHTRANGE = 100;
  1610.     MY.AMBIENT = 100;
  1611.  
  1612.     MY.SKILL2 = shot_speed.x;
  1613.     MY.SKILL3 = shot_speed.y;
  1614.     MY.SKILL4 = shot_speed.z;
  1615.     MY._DAMAGE = damage;
  1616.     MY._FIREMODE = fire_mode;
  1617.  
  1618.       // my.near is set by the explosion
  1619.     while(MY.NEAR != ON)
  1620.     {
  1621.         wait(1); // wait at the loop beginning, to let it appear at the start position
  1622.  
  1623.         temp = TIME;
  1624.         if(temp > 1.5) { temp = 1.5; }    // make bullet slower on slow PCs
  1625. // MOVE moves by a distance, so multiply the speed by time.
  1626.         fireball_speed.x = MY.SKILL2 * temp;
  1627.         fireball_speed.y = MY.SKILL3 * temp;
  1628.         fireball_speed.z = MY.SKILL4 * temp;
  1629.  
  1630.         if((MY._FIREMODE & BULLET_SMOKETRAIL) == BULLET_SMOKETRAIL)
  1631.         {
  1632.             temp = 3 * TIME;
  1633.             if(temp > 6) { temp = 6; }    // generate max 6 particels
  1634.             emit(temp,MY.POS,particle_fade);     // smoke trail
  1635.         }
  1636.  
  1637.         vec_scale(fireball_speed,movement_scale);    // scale fireball_speed by movement_scale
  1638.          //--move(ME,nullskill,fireball_speed);
  1639.         move_mode = ignore_you + ignore_passable + activate_trigger;
  1640.         result = ent_move(nullskill,fireball_speed);
  1641.     }
  1642. }
  1643.  
  1644.  
  1645.  
  1646.  
  1647. // Desc: launch a rocket (models)
  1648. //
  1649. //
  1650. // Mod:  06/08/01 DCP
  1651. //            Replaced move() with ent_move()
  1652. function rocket_launch()
  1653. {
  1654.     vec_scale(MY.SCALE_X,actor_scale);    // use actor_scale
  1655.  
  1656.      MY.ENABLE_BLOCK =  ON;      // collision with map surface
  1657.     MY.ENABLE_ENTITY =  ON;     // collision with entity
  1658.      MY.ENABLE_STUCK = ON;
  1659.     MY.ENABLE_IMPACT = ON;
  1660.     MY.ENABLE_PUSH = ON;
  1661.      MY.EVENT = _rocket_event;
  1662.  
  1663.     MY.AMBIENT = 100;  // bright
  1664.     MY.LIGHTRANGE = 150;
  1665.     MY.LIGHTRED = 250;
  1666.     MY.LIGHTGREEN = 50;
  1667.     MY.LIGHTBLUE = 50;
  1668.  
  1669. //-     MY.PAN = YOUR.PAN; // the rocket start in the same direction than this 'emitter'
  1670. //-     MY.TILT = YOUR.TILT;
  1671. //-     MY.ROLL = YOUR.ROLL;
  1672.     vec_to_angle(MY.PAN, shot_speed);
  1673.  
  1674.     MY.SKILL2 = shot_speed.x;
  1675.     MY.SKILL3 = shot_speed.y;
  1676.     MY.SKILL4 = shot_speed.z;
  1677.     MY._DAMAGE = damage;
  1678.     MY._FIREMODE = fire_mode;
  1679.  
  1680.     MY.SKILL9 = 250; // 'burn time'  (fuel)
  1681.     while(MY.SKILL9 > 0)
  1682.     {
  1683.         temp.X = MY.SKILL2 * TIME;
  1684.         temp.Y = MY.SKILL3 * TIME;
  1685.         temp.Z = MY.SKILL4 * TIME;
  1686.           vec_scale(temp,movement_scale);    // scale distance by movement_scale
  1687. //--        move(ME,NULLSKILL,temp);
  1688.         move_mode = ignore_you + ignore_passable + activate_trigger;
  1689.         result = ent_move(nullskill,temp);
  1690.  
  1691.         emit(3,MY.POS,particle_smoke);    // emit( smoke
  1692.         MY.SKILL9 -= TIME;  // burn fuel
  1693.         waitt(1);     // update position once per tick
  1694.     }
  1695.     _rocket_event();   // explode when out of fuel
  1696. }
  1697.  
  1698.  
  1699.  
  1700. // Desc: actor "explode" :
  1701. //                face camera
  1702. //                play explosion sound
  1703. //                animate frames
  1704. //                  remove
  1705. ACTION actor_explode
  1706. {
  1707.     MY.FACING = ON;    // face the camera
  1708.     MY.NEAR = ON;
  1709.     MY.FLARE = ON;
  1710.     MY.PASSABLE = ON;    // don't push the player through walls
  1711.     MY.FRAME = 1;
  1712.     wait(1);
  1713.  
  1714.     PLAY_ENTSOUND ME,explo_wham,1000;
  1715.     MY.LIGHTRED = light_explo.RED;
  1716.     MY.LIGHTGREEN = light_explo.GREEN;
  1717.     MY.LIGHTBLUE = light_explo.BLUE;
  1718.     MY.AMBIENT = 100;
  1719.     MY.LIGHTRANGE += 50;
  1720.  
  1721.     // use the new sprite animation
  1722.     while(MY.FRAME < MY._DIEFRAMES)
  1723.     {
  1724.         wait(1);
  1725.         MY.LIGHTRANGE += 15;
  1726.         MY.LIGHTRED += 20 * TIME;    // fade to red
  1727.         MY.LIGHTBLUE -= 20 * TIME;
  1728.         MY.FRAME += TIME;
  1729.     }
  1730.     wait(1);
  1731.     remove(ME);
  1732. }
  1733.  
  1734.  
  1735. // Desc: create a hit point 'effect' depending on (fire_mode & MODE_HIT) value
  1736. //
  1737. // Input:fire_mode
  1738. //            TARGET
  1739. //
  1740. function _hit_point_effect()
  1741. {
  1742.     // flash at hit point?
  1743.     if((fire_mode & MODE_HIT) == HIT_FLASH)
  1744.     {
  1745.         weaponTmpSyn = YOU;  // save YOU value
  1746.         create(small_flash,TARGET,_blowup);
  1747.         YOU = weaponTmpSyn;
  1748.     }
  1749.  
  1750.     // smoke at hit point?
  1751.     if(fire_mode & HIT_SMOKE)
  1752.     {
  1753.          emit(20,TARGET,particle_smoke); // emit smoke
  1754.     }
  1755.  
  1756.     if(fire_mode & HIT_SPARKS)
  1757.     {
  1758.         emit(20,TARGET,particle_scatter); // emit sparks
  1759.     }
  1760.  
  1761.     // bullet hole ***
  1762.     if(fire_mode & HIT_HOLE)
  1763.     {
  1764.         if(YOU == NULL)    // hit wall (not entity)
  1765.         {
  1766.             create(bullethole_map,TARGET,bullet_hole);  // create bullet hole
  1767.         }
  1768.     }
  1769. }
  1770.  
  1771.  
  1772. var    bullet_hole_index = 0;
  1773. DEFINE    kMaxBulletHole    100;
  1774. var    h_bullet_hole_array[kMaxBulletHole];
  1775. entity* p_bullet_hole_temp;
  1776.  
  1777. // Desc: bullet hole
  1778. //
  1779. // Mod Date: 07/14/01
  1780. //        Use new handles to turned it into an FIFO array
  1781. // Mod Date: 07/16/01
  1782. //        Fixed index problem with remove (use SKILL4 to store local index)
  1783. // PROBLEM: 07/26/01
  1784. //        If you change levels with 'outstanding' bullet holes you will get
  1785. //    'WDL Crash' errors when this function tries to remove the hole from the
  1786. //    previous level. Solution: clear all bullet_holes before switching levels
  1787. //    by calling 'bullet_hole_remove_all()'.
  1788. function bullet_hole()
  1789. {
  1790.     // check for maximum bullet holes at any time
  1791.     if(bullet_hole_index >= kMaxBulletHole)
  1792.     {
  1793.         bullet_hole_index = 0;
  1794.     }
  1795.  
  1796.     // check to see if its already in use
  1797.     temp = h_bullet_hole_array[bullet_hole_index];
  1798.     if(temp != 0)
  1799.     {
  1800.         // remove old hole
  1801.         p_bullet_hole_temp = ptr_for_handle(temp);
  1802.         remove(p_bullet_hole_temp);
  1803.     }
  1804.  
  1805.     // assign this as the new value in the array
  1806.     h_bullet_hole_array[bullet_hole_index] = handle(ME);
  1807.     MY.SKILL4 = bullet_hole_index;  // save index for removal
  1808.  
  1809.     bullet_hole_index += 1;        // increament index
  1810.  
  1811.     MY.TRANSPARENT = ON;
  1812.     MY.FLARE = ON;
  1813.     MY.PASSABLE = ON;
  1814.  
  1815.     MY.ORIENTED = ON;
  1816.  
  1817.     vec_to_angle(MY.PAN,NORMAL);    // rotate to target normal
  1818.  
  1819.     waitt(160);          // time bullet stays before vanishing
  1820.  
  1821.     // alpha fade
  1822.     while(MY.ALPHA > 0)
  1823.     {
  1824.         MY.ALPHA -= TIME;
  1825.         waitt(1);
  1826.     }
  1827.  
  1828.     h_bullet_hole_array[MY.SKILL4] = 0;    // zero out pointer
  1829.     remove(ME);
  1830. }
  1831.  
  1832. // Desc: remove all bullet holes
  1833. // Note: Call this before changing levels.
  1834. function    bullet_hole_remove_all()
  1835. {
  1836.     bullet_hole_index = 0;
  1837.     while(bullet_hole_index < kMaxBulletHole)
  1838.     {
  1839.         temp = h_bullet_hole_array[bullet_hole_index];
  1840.         if(temp != 0)
  1841.         {
  1842.             // remove old hole
  1843.             p_bullet_hole_temp = ptr_for_handle(temp);
  1844.             remove(p_bullet_hole_temp);
  1845.             h_bullet_hole_array[bullet_hole_index] = 0;    // zero out pointer
  1846.         }
  1847.         bullet_hole_index += 1;
  1848.     }
  1849. }
  1850.  
  1851.  
  1852.  
  1853. // Desc: scale and remove the laser beam
  1854. //
  1855. // Uses: TARGET,
  1856. //
  1857. // ToDo: make work in 3D player mode
  1858. //
  1859. // Mod:  04/18/01 DCP
  1860. //     Use 'vec_to_angle' and shot_speed to determine beam orientation
  1861. //
  1862. // Mod: 08/01/01 DCP
  1863. //        Made laser brighter
  1864. function    laser_fire()
  1865. {
  1866.     MY.PASSABLE = ON;
  1867.    MY.LIGHT = ON;       // illuminate myself
  1868.     MY.LIGHTRED = 255;   // red laser
  1869.     MY.TRANSPARENT = ON;
  1870.     MY.ALPHA = 95;
  1871.     MY.BLEND = ON;
  1872.     MY.FLARE = ON;
  1873.  
  1874.     if(RESULT == 0)
  1875.     {
  1876.         // set the lightrange
  1877.         MY.LIGHTRANGE =  vec_length(shot_speed)/2;
  1878.         // scale the beam
  1879.         MY.SCALE_X = MY.LIGHTRANGE/50;
  1880.         // move the beam (center halfway to target)
  1881.         vec_add(MY.X,shot_speed.X);
  1882.  
  1883.     }
  1884.     else
  1885.     {
  1886.         // set the lightrange
  1887.         MY.LIGHTRANGE = RESULT/2;//200;
  1888.  
  1889.         MY.SCALE_X = RESULT/200.0; // 200 = beam length
  1890.         // move the beam (center halfway to target)
  1891.         vec_set(temp,TARGET);    // temp = TARGET
  1892.         vec_sub(temp,ME.X);     // temp = TARGET - ME.X
  1893.         vec_scale(temp,0.5);    // temp = (TARGET - ME.X)/2
  1894.         vec_add(MY.X,temp);
  1895.     }
  1896. //-    vec_set(MY.PAN,YOUR.PAN);    // rotate the beam
  1897.     vec_to_angle(MY.PAN, shot_speed);
  1898.  
  1899.  
  1900.  
  1901.     WAITT(4);
  1902.     REMOVE(ME);
  1903.  
  1904. }
  1905.  
  1906. ////////////////////////////////////////////////////////////////////////
  1907. // Cross-hair panel and functions
  1908. //
  1909. // Use the var 'cross_pos.x' and 'cross_pos.y' you adjust the position
  1910. //of the cross-hair on the screen
  1911.  
  1912. BMAP    cross_bmp, <cross.pcx>;
  1913. var cross_pos[2] = 0, 0;    // position of cross-hair on screen
  1914.  
  1915. PANEL    cross_pan
  1916. {
  1917.     bmap = cross_bmp;
  1918.     layer = 1;
  1919.     flags = overlay, transparent, refresh, d3d;
  1920. }
  1921.  
  1922. // Desc: position the cross-hair panel at the center of the screen
  1923. //        and make it visible.
  1924. function    pan_cross_show()
  1925. {
  1926.     cross_pan.pos_x = (screen_size.x / 2) + cross_pos.x;
  1927.     cross_pan.pos_y = (screen_size.y / 2) + cross_pos.y;
  1928.     cross_pan.visible = ON;
  1929.  
  1930. }
  1931.  
  1932. // Desc: hide the cross-hair panel
  1933. function    pan_cross_hide()
  1934. {
  1935.     cross_pan.visible = OFF;
  1936. }
  1937.  
  1938.  
  1939. // Desc: toggle cross-hair panel
  1940. function    pan_cross_toggle()
  1941. {
  1942.     if(cross_pan.visible == OFF) { pan_cross_show(); }
  1943.     else { pan_cross_hide(); }
  1944. }
  1945.  
  1946.  
  1947. /////////////////////////////////////////////////////////////
  1948. // ON_KEY Define
  1949. ON_CTRL weapon_fire;
  1950. ON_MOUSE_LEFT weapon_fire;
  1951.  
  1952. ON_E gun_select_cycle_up;
  1953. ON_Q gun_select_cycle_down;
  1954.  
  1955. ON_K    pan_cross_toggle;